Skip to content

Torch version 2.7.0 update#1552

Merged
rahulga1 merged 17 commits intosecurefederatedai:developfrom
tanwarsh:torch-2.6
May 5, 2025
Merged

Torch version 2.7.0 update#1552
rahulga1 merged 17 commits intosecurefederatedai:developfrom
tanwarsh:torch-2.6

Conversation

@tanwarsh
Copy link
Copy Markdown
Collaborator

@tanwarsh tanwarsh commented Apr 22, 2025

Summary

Pytorch version updated to 2.7.0.
torchvision version updated to 0.22.0.
pinned pip version to 24.1.2 to avoid error Type parameter +RV without a default follows type parameter with a default

Type of Change (Mandatory)

Specify the type of change being made.

  • Security improvement

Description (Mandatory)

Updated torch version to fix https://github.com/securefederatedai/openfl/security/dependabot/1979 to https://github.com/securefederatedai/openfl/security/dependabot/1999

Signed-off-by: yes <shailesh.tanwar@intel.com>
Signed-off-by: yes <shailesh.tanwar@intel.com>
Signed-off-by: yes <shailesh.tanwar@intel.com>
@tanwarsh tanwarsh changed the title WIP: torch version update Torch version 2.6.0 update Apr 23, 2025
@psfoley
Copy link
Copy Markdown
Contributor

psfoley commented Apr 24, 2025

@tanwarsh can you elaborate on why the pinning of pip is necessary? If it's necessary in CI, is it also necessary for users of OpenFL? Also - PyTorch 2.7 was just released today. It might be worth just jumping straight to that.

Signed-off-by: yes <shailesh.tanwar@intel.com>
Signed-off-by: yes <shailesh.tanwar@intel.com>
@tanwarsh
Copy link
Copy Markdown
Collaborator Author

tanwarsh commented Apr 24, 2025

@psfoley, Thanks for the review.
I have updated version to 2.7.0.

Pinning pip version is necessary because of issue logged here #1441.

@tanwarsh tanwarsh changed the title Torch version 2.6.0 update Torch version 2.7.0 update Apr 24, 2025
Copy link
Copy Markdown
Collaborator

@MasterSkepticista MasterSkepticista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on @psfoley's concern. I am not in favor of pinning pip. If bumping torch does not solve this problem, might as well not 'fix' this in the current way right now.

Of all packages, pip is seen as an inert package in and of itself. I recommend revisiting this based on user feedback/issues being raised.

@psfoley
Copy link
Copy Markdown
Contributor

psfoley commented Apr 25, 2025

We can't rely on users to use a specific pip version. My recommendation would be to add @kta-intel's patch directly before the PyTorchDataLoader import; that way we maintain compatibility across all PyTorch and pip versions. No user modifications are required:

#openfl/federated/__init__.py
...
if util.find_spec("torch") is not None:
    os.environ["SETUPTOOLS_USE_DISTUTILS"] = "stdlib"
    import sys
    import typing_extensions
    sys.modules["pip._vendor.typing_extensions"] = typing_extensions
    from openfl.federated.data import PyTorchDataLoader
    from openfl.federated.task import PyTorchTaskRunner
...

Tested this and confirmed working with PyTorch 2.6.0 and pip 25.0.1, as well as PyTorch 2.4.1 and pip 24.1.2

As an aside, I was not able to install Pytorch 2.7 with Python 3.10. Anyone else facing this issue?

Copy link
Copy Markdown
Contributor

@psfoley psfoley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes here: #1552 (comment)

Signed-off-by: yes <shailesh.tanwar@intel.com>
tanwarsh and others added 3 commits April 30, 2025 15:04
Signed-off-by: yes <shailesh.tanwar@intel.com>
Signed-off-by: yes <shailesh.tanwar@intel.com>
@tanwarsh
Copy link
Copy Markdown
Collaborator Author

We can't rely on users to use a specific pip version. My recommendation would be to add @kta-intel's patch directly before the PyTorchDataLoader import; that way we maintain compatibility across all PyTorch and pip versions. No user modifications are required:

#openfl/federated/__init__.py
...
if util.find_spec("torch") is not None:
    os.environ["SETUPTOOLS_USE_DISTUTILS"] = "stdlib"
    import sys
    import typing_extensions
    sys.modules["pip._vendor.typing_extensions"] = typing_extensions
    from openfl.federated.data import PyTorchDataLoader
    from openfl.federated.task import PyTorchTaskRunner
...

Tested this and confirmed working with PyTorch 2.6.0 and pip 25.0.1, as well as PyTorch 2.4.1 and pip 24.1.2

As an aside, I was not able to install Pytorch 2.7 with Python 3.10. Anyone else facing this issue?

@psfoley, I have added the patch.

I am able to install Pytorch 2.7 with Python 3.10.

Copy link
Copy Markdown
Collaborator

@MasterSkepticista MasterSkepticista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request placing a warning before the patch is applied in code to notify the development team and users. Else it may lead to inadvertent silent errors should this be fixed by PyTorch team in the future.

Copy link
Copy Markdown
Collaborator

@teoparvanov teoparvanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but please wait for the PQ pipeline to be stabilized before merging into develop:
https://github.com/securefederatedai/openfl/actions/workflows/pq_pipeline.yml

tanwarsh and others added 2 commits May 2, 2025 14:39
Signed-off-by: yes <shailesh.tanwar@intel.com>
@tanwarsh
Copy link
Copy Markdown
Collaborator Author

tanwarsh commented May 2, 2025

Approved, but please wait for the PQ pipeline to be stabilized before merging into develop: https://github.com/securefederatedai/openfl/actions/workflows/pq_pipeline.yml

@teoparvanov, for version >=2.5.0 the file are no longer generated by PyTorch in tmp folder and hence the pipeline was failing. Added code to omit file check in tmp folder.

@rahulga1 rahulga1 merged commit 9a9eec2 into securefederatedai:develop May 5, 2025
35 checks passed
payalcha pushed a commit to payalcha/openfl that referenced this pull request May 6, 2025
* torch version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* update ti 2.7.0

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version pinned

Signed-off-by: yes <shailesh.tanwar@intel.com>

* code changes

Signed-off-by: yes <shailesh.tanwar@intel.com>

* code format

Signed-off-by: yes <shailesh.tanwar@intel.com>

* omit pytorch generated files

Signed-off-by: yes <shailesh.tanwar@intel.com>

---------

Signed-off-by: yes <shailesh.tanwar@intel.com>
Co-authored-by: teoparvanov <teodor.parvanov@intel.com>
Signed-off-by: Chaurasiya, Payal <payal.chaurasiya@intel.com>
tayfunceylan pushed a commit to tayfunceylan/openfl that referenced this pull request May 23, 2025
* torch version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version update

Signed-off-by: yes <shailesh.tanwar@intel.com>

* update ti 2.7.0

Signed-off-by: yes <shailesh.tanwar@intel.com>

* pip version pinned

Signed-off-by: yes <shailesh.tanwar@intel.com>

* code changes

Signed-off-by: yes <shailesh.tanwar@intel.com>

* code format

Signed-off-by: yes <shailesh.tanwar@intel.com>

* omit pytorch generated files

Signed-off-by: yes <shailesh.tanwar@intel.com>

---------

Signed-off-by: yes <shailesh.tanwar@intel.com>
Co-authored-by: teoparvanov <teodor.parvanov@intel.com>
Signed-off-by: Tayfun Ceylan <tayfun.ceylan>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants